{include file="public/toper" /}
<div class="layui-tab layui-tab-brief main-tab-container" lay-filter="main-tab">
    <ul class="layui-tab-title main-tab-title">
        <a href="{:url('setting/sitemap')}"><li class="layui-this">Sitemap</li></a>
        <div class="main-tab-item">相关设置</div>
    </ul>
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show" style="min-height: 800px">
            <form class="layui-form">
                <div class="layui-form-item">
                    <label class="layui-form-label">选择模型</label>
                    <div class="layui-input-inline input-custom-width">
                        {foreach name="$models" id="mo"}
                            {if condition="$mo['id'] neq 4"}
                                <input type="checkbox" name="sitemap_model[]" value="{$mo.id}" title="{$mo.name}" {if condition="in_array($mo['id'],$setting['sitemap_model'])"} checked {/if}>

                        {/if}
                        {/foreach}
                    </div>
                    <div class="layui-form-mid layui-word-aux"></div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">更新频率</label>
                    <div class="layui-input-inline input-custom-width">
                        <select name="changefreq" lay-verify="required">
                            <option value="">请选择</option>
                            {foreach name="$changefreq_select" id="cha"}
                                <option value="{$key}" {if condition="$key eq $setting['changefreq']"} selected {/if}>{$cha}</option>
                            {/foreach}
                        </select>
                    </div>
                    <div class="layui-form-mid layui-word-aux"></div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="sitemap">立即生成</button>
                    </div>
                </div>
                <div class="fill_100"></div><div class="fill_100"></div>
            </form>
        </div>
    </div>
</div>
<script>
    layui.use(['form', 'element'], function(){
        var element = layui.element //Tab的切换功能，切换事件监听等，需要依赖element模块
            ,form = layui.form
            ,jq = layui.jquery;

        //监听提交

        form.on('submit(sitemap)', function(data){
            loading = layer.load(2, {
                shade: [0.2,'#000'] //0.2透明度的白色背景
            });
            var param = data.field;
            jq.post(
                '{:url("setting/sitemapPost")}',
                param,
                function(data){
                    if(data.code == 200){
                        layer.close(loading);
                        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                            location.reload();//do something
                        });
                    }else{
                        layer.close(loading);
                        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
                    }
                }).error(function () {
                layer.msg('服务器出错', {icon: 2, anim: 6, time: 1000});
            });
            layer.close(loading);
            return false;
        });
    });
</script>
</body>
</html>